Skip to content

Only enable BedrockSession packet logging in debug mode#6313

Merged
onebeastchris merged 1 commit into
GeyserMC:masterfrom
iwmedia:feature/bedrock-session-debug-logging
Apr 26, 2026
Merged

Only enable BedrockSession packet logging in debug mode#6313
onebeastchris merged 1 commit into
GeyserMC:masterfrom
iwmedia:feature/bedrock-session-debug-logging

Conversation

@ByteExceptionM

Copy link
Copy Markdown
Contributor

With setLogging(true), every inbound and outbound Bedrock packet triggers BedrockSession.logInbound/logOutbound. These call log.trace(...) with the packet as a parameter, which materializes packet.toString() and routes the record through SLF4J.

Normally an SLF4J TRACE call is cheap when the underlying logger filters it out - the record never gets constructed. But this breaks down on BungeeCord.

BungeeCord's BungeeLogger sets its root logger to Level.ALL. Every SLF4J call made from within BungeeCord's classloader (which includes Geyser when run as a plugin) is routed through JDK14LoggerFactory.LOGGER, which points at that same Level.ALL logger. Because the logger accepts everything, the TRACE record is fully constructed - fillCallerData(), Throwable.getStackTrace(), MessageFormatter parameter expansion, packet.toString() - and only discarded later at the handler level.

The result: on BungeeCord, every single Bedrock packet pays the full log-record construction cost, even though no log output is ever produced. The fix is to not ask for packet logging in the first place unless the user actually wants it.

Copilot AI review requested due to automatic review settings April 19, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Geyser’s Bedrock session initialization to avoid enabling Cloudburst Bedrock packet logging unless Geyser is running in debug mode, preventing unnecessary per-packet log-record construction overhead (notably on BungeeCord due to its logging configuration).

Changes:

  • Gate BedrockServerSession packet logging behind config().debugMode() instead of always enabling it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Tim203

Tim203 commented Apr 19, 2026

Copy link
Copy Markdown
Member

I understand that this is a simple fix and I appreciate the PR, but am I crazy to suggest that we should fix this in BungeeCord instead? This feels like one of those things that we could eventually remove as unneeded code, which is fair because the logger says that tracing is enabled.

@ByteExceptionM

Copy link
Copy Markdown
Contributor Author

I understand that this is a simple fix and I appreciate the PR, but am I crazy to suggest that we should fix this in BungeeCord instead? This feels like one of those things that we could eventually remove as unneeded code, which is fair because the logger says that tracing is enabled.

That's a fair point and was my first instinct too. I've been already in touch with the BungeeCord maintainers about this - fixing it on their end would be a breaking change, since plugins and downstream forks rely on the current Level.ALL behavior for their own logging. So it's not something that can realistically land there.

Gating this behind debugMode in Geyser doesn't break anything (packet logging still works when users actually want it via the config option) and avoids the per-packet overhead for everyone else. Given that the BungeeCord fix isn't on the table, I think this is the pragmatic place to handle it.

@onebeastchris onebeastchris merged commit 0cc3317 into GeyserMC:master Apr 26, 2026
5 of 6 checks passed
@ByteExceptionM ByteExceptionM deleted the feature/bedrock-session-debug-logging branch April 27, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants